$(function () {
	vm.getXmjz();
	vm.getGzJzList();
	vm.getNewMentors();
	vm.getNewStudents();
});

var vm = new Vue({
	el:'#mapp',
	data:{
		title: "",
		//项目进展
		bsnXmjz: {},
		//关注与捐赠
		bsnGzJzList: {},
		bsnMentorList: {},
		bsnStudentList: {},
		pageParams: {
			limit: "200",
			page: "1"
		}
	},
	methods: {
		//读取项目进展
		getXmjz: function(){
			$.get(ajaxServerUrlG("bsnXmjz/info/xmjz"), function(r){
                vm.bsnXmjz = r.bsnGonggao;
            });
		},
		getGzJzList: function(){
			$.ajax({
				type: "POST",
			    url: ajaxServerUrlG("bsnGzJz/list"),
                contentType: "application/json",
			    data: JSON.stringify({
					limit: "10",
					page: "1"
				}),
			    success: function(r){
			    	if(r.code === 0){
						vm.bsnGzJzList = r.page.list;
					}else{
						alert(r.msg);
					}
				}
			});
		},
		//读取新增导师
		getNewMentors: function(){
			$.ajax({
				type: "POST",
			    url: ajaxServerUrlG("bsnmentor/list"),
                contentType: "application/json",
			    data: JSON.stringify(vm.pageParams),
			    success: function(r){
			    	if(r.code === 0){
						vm.bsnMentorList = r.page.list;
					}else{
						alert(r.msg);
					}
				}
			});
		},
		//读取新增儿童
		getNewStudents: function(){
			$.ajax({
				type: "POST",
			    url: ajaxServerUrlG("bsnstudent/list"),
                contentType: "application/json",
			    data: JSON.stringify(vm.pageParams),
			    success: function(r){
			    	if(r.code === 0){
						vm.bsnStudentList = r.page.list;
					}else{
						alert(r.msg);
					}
				}
			});
		}		
	},
	filters: {
		/*过滤并替换头像 */
		mentorImgFilter: function (imgUrl, xingb) {
			if (StringUtils.isNotEmpty(imgUrl)) {
				return imgUrl;
			}
			if (xingb == "男") {
				return "images/man@2x.png";
			} else {
				return "images/woman@2x.png";
			}
		},
		/*过滤并替换头像 */
		studentImgFilter: function (imgUrl, xingb) {
			if (StringUtils.isNotEmpty(imgUrl)) {
				return imgUrl;
			}
			if (xingb == "男") {
				return "images/boy.png";
			} else {
				return "images/girl.png";
			}
		},
		dateFormat: function (timeStr) {
			if (StringUtils.isNotEmpty(timeStr)) {
				var tmp = timeStr.split(" ");
				console.log(tmp);
				return tmp[0]; 
			}
		}
	}
});